<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>3943：[Usaco2015 Feb]SuperBull</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Feb]SuperBull</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[Usaco2015 Feb]SuperBull</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [Usaco2015 Feb]SuperBull                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div>
<div>Bessie and her friends are playing hoofball in the annual Superbull championship, and Farmer John is</div>
<div>&nbsp;in charge of making the tournament as exciting as possible. A total of N (1 &lt;= N &lt;= 2000) teams are</div>
<div>&nbsp;playing in the Superbull. Each team is assigned a distinct integer team ID in the range 1...2^30-1&nbsp;</div>
<div>to distinguish it from the other teams. The Superbull is an elimination tournament -- after every ga</div>
<div>me, Farmer John chooses which team to eliminate from the Superbull, and the eliminated team can no l</div>
<div>onger play in any more games. The Superbull ends when only one team remains.Farmer John notices a ve</div>
<div>ry unusual property about the scores in matches! In any game, the combined score of the two teams al</div>
<div>ways ends up being the bitwise exclusive OR (XOR) of the two team IDs. For example, if teams 12 and&nbsp;</div>
<div>20 were to play, then 24 points would be scored in that game, since 01100 XOR 10100 = 11000.Farmer J</div>
<div>ohn believes that the more points are scored in a game, the more exciting the game is. Because of th</div>
<div>is, he wants to choose a series of games to be played such that the total number of points scored in</div>
<div>&nbsp;the Superbull is maximized. Please help Farmer John organize the matches.</div>
<div>贝西和她的朋友们在参加一年一度的&ldquo;犇&rdquo;(足)球锦标赛。FJ的任务是让这场锦标赛尽可能地好看。一共有N支球</div>
<div>队参加这场比赛，每支球队都有一个特有的取值在1-230-1之间的整数编号(即：所有球队编号各不相同)。&ldquo;犇&rdquo;</div>
<div>锦标赛是一个淘汰赛制的比赛&mdash;&mdash;每场比赛过后，FJ选择一支球队淘汰，淘汰了的球队将不能再参加比赛。锦标赛</div>
<div>在只有一支球队留下的时候就结束了。FJ发现了一个神奇的规律：在任意一场比赛中，这场比赛的得分是参加比赛</div>
<div>两队的编号的异或(Xor)值。例如：编号为12的队伍和编号为20的队伍之间的比赛的得分是24分，因为 12(01100)&nbsp;</div>
<div>Xor 20(10100) = 24(11000)。FJ相信比赛的得分越高，比赛就越好看，因此，他希望安排一个比赛顺序，使得所</div>
<div>有比赛的得分和最高。请帮助FJ决定比赛的顺序</div>
</div>
<p></p>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
<p></p></p><hr/><h3>输入格式</h3><p><div>
<div>
<div>The first line contains the single integer N. The following N lines contain the N team IDs.</div>
<div>第一行包含一个整数N接下来的N行包含N个整数，第i个整数代表第i支队伍的编号,&nbsp;1&lt;=N&lt;=2000</div>
</div>
</div>
<div>
<p></p>
</div>
<div>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
</div>
<p></p></p><hr/><h3>输出格式</h3><p><h4 style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;">
<div>
<div>Output the maximum possible number of points that can be scored in the Superbull.</div>
<div>一行，一个整数，表示锦标赛的所有比赛的得分的最大值</div>
</div>
</h4>
<p style="font-family: Raleway, 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px;"></p>
<p></p></p><hr/><h3>样例输入</h3><pre>4
3
6
9
10</pre><hr/><h3>样例输出</h3><pre>37
</pre><hr/><h3>提示</h3><p><div>样例解释：</div>
<div>FJ先让编号为3和编号为9的队伍进行比赛，然后让编号为9的队伍赢得比赛(淘汰编号为6的队伍)，现在</div>
<div>剩下了编号为6910的队伍。然后他让编号为6和编号为9的队伍比赛，然后让编号为6的队伍赢得比赛。现在编号为6</div>
<div>10的队伍留了下来最后让编号为6和编号为10的队伍比赛，让编号为10的队伍赢得比赛。所有比赛的得分和就是：(</div>
<div>3Xor9)+(6Xor9)+(6Xor10)=10+15+12=37</div></p><hr/><h3>题目来源</h3><p>Silver</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=3943" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=3943" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>